Title: SQL W3S (By-BKK) / 016 MIN MAX
Tags: Obsidian_to_Anki

Q: What does SQL MIN() do?
A: Returns the smallest value of the selected column

Q: What does SQL MAX() do?
A: Returns the largest value of the selected column

Q: How do you find the lowest price in a column named Price?
A: Use SELECT MIN(Price) FROM Products;

Q: How do you find the highest price in a column named Price?
A: Use SELECT MAX(Price) FROM Products;

Q: True or False: MIN() returns the largest value in a column.
A: False

Q: True or False: MAX() returns the highest value in a column.
A: True

Q: Which SQL function helps to get the largest value in a column?
A: MAX()

Q: Which SQL function finds the smallest value in a column?
A: MIN()

Q: What is the syntax for finding the minimum value in a table?
A: SELECT MIN(column_name) FROM table_name WHERE condition;

Q: What is the syntax for finding the maximum value in a table?
A: SELECT MAX(column_name) FROM table_name WHERE condition;

Q: How can you rename the result column for MIN() in SQL?
A: Use AS keyword, for example: SELECT MIN(Price) AS SmallestPrice FROM Products;

Q: How can you rename the result column for MAX() in SQL?
A: Use AS keyword, for example: SELECT MAX(Price) AS LargestPrice FROM Products;

Q: How do you use MIN() with GROUP BY?
A: SELECT MIN(Price) AS SmallestPrice, CategoryID FROM Products GROUP BY CategoryID;

Q: MIN() finds the smallest value. What is the keyword to rename its result column?
A: AS

Q: Give an example SQL query that shows the highest price for each category.
A: SELECT MAX(Price) AS HighestPrice, CategoryID FROM Products GROUP BY CategoryID;

Q: Returns the smallest value of a column. What is the SQL function?
A: MIN()

Q: Returns the largest value of a column. What is the SQL function?
A: MAX()

Q: MIN() and MAX() functions always work with what type of data?
A: Numeric or date values

Q: SELECT MIN(Price) FROM Products;
A: Finds the lowest price in the Products table

Q: SELECT MAX(Price) FROM Products;
A: Finds the highest price in the Products table